package com.ibl.rover.lite.service.utill;

 import java.net.URL;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.ibl.rover.lite.service.RoverListner;

 
 
public class HibernateUtill {
	private static final SessionFactory sessionFactory;
	private static String path = "/hibernate.cfg.xml";
	static {
		try {
			URL url = RoverListner.class.getResource(path);
			
			// Create the SessionFactory from hibernate.cfg.xml
			sessionFactory = new Configuration().configure(url)
					.buildSessionFactory();
		} catch (Throwable ex) {
			// Make sure you log the exception, as it might be swallowed
			System.err.println("Initial SessionFactory creation failed." + ex);
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}
